package thread;

/**
 * Created by User on 2017/10/27.
 */
public class Test {


    public static void main(String[] args) {
        final long startTime = System.currentTimeMillis();


        System.out.println("线程一开始：：---");
        DynamicAsyncTaskService.getInstance().execute(new Runnable() {
            @Override
            public void run() {
                try {
                    System.out.println("正在运行线程名字：" + Thread.currentThread().getName());
                    System.out.println("线程池中现在的线程数目是：" + DynamicAsyncTaskService.getInstance().getActiveNum(1) + ",队列中正在等待执行的任务数量为：" + DynamicAsyncTaskService.getInstance().getQueueNum(1)
                            + ",可利用的线程数目：" + DynamicAsyncTaskService.getInstance().getAvailableNum(1)
                    );
                    Thread.sleep(1000);
                    long endTime = System.currentTimeMillis();
                    System.out.println(Thread.currentThread().getName() + "结束时间" + (endTime - startTime));
                    System.out.println("线程池中现在的线程数目是：" + DynamicAsyncTaskService.getInstance().getActiveNum(1) + ",队列中正在等待执行的任务数量为：" + DynamicAsyncTaskService.getInstance().getQueueNum(1)
                            + ",可利用的线程数目：" + DynamicAsyncTaskService.getInstance().getAvailableNum(1)
                    );
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, 1);


    }
}
